package com.sgxy.wmservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sgxy.servicebase.exceptionhandler.ERPException;
import com.sgxy.wmservice.entity.WmInputOrder;
import com.sgxy.wmservice.entity.WmStore;
import com.sgxy.wmservice.entity.WmStoreGoods;
import com.sgxy.wmservice.entity.vo.StoreGoodsVo;
import com.sgxy.wmservice.entity.vo.StoreVo;
import com.sgxy.wmservice.mapper.WmStoreMapper;
import com.sgxy.wmservice.service.WmStoreService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author testjava
 * @since 2022-04-29
 */
@Service
public class WmStoreServiceImpl extends ServiceImpl<WmStoreMapper, WmStore> implements WmStoreService {

    //todo 删除仓库
    @Override
    public Boolean deleteStore(String id) {
        //QueryWrapper<WmInputOrder> wrapper = new QueryWrapper<>();
        //wrapper.eq("input_id",id);
        //int count = wmInputOrderService.count(wrapper);
        //if(count>0){
        //    throw new ERPException(20001,"该数据正被使用，无法删除");
        //}
        baseMapper.deleteById(id);
        return true;
    }

    @Override
    public IPage<StoreVo> selectPageVoList(Page<StoreVo> sPage, WmStore wmStore) {
        return baseMapper.selectPageVoList(sPage,wmStore);
    }

    @Override
    public StoreVo getStoreInfoById(String id) {
        return baseMapper.selectOneById(id);
    }
}
